
import axios from '@/functions/request';
// function getList(params){
//     return new Promise((resolve, reject)=>{
//         axios.formPost( "/api/auth/sysuser/doGetList",params).then(res=>{
//             resolve(res)
//         }).catch(e => {
//             reject(e)
//         });
//     })
    
// }
var statusMap = {'1': '成功', '2': '失败'};
var operateTypeMap = {'1': '登录', '2': '操作','3': '错误', '4': '变更'};
function getLogTypeName(row, column) {
    let operateType = row[column.property];
    return operateTypeMap[operateType];
}
function  getStatusName(row, column) {
    let status = row[column.property];
    return statusMap[status];
}
function dateFormatter(row, column) {
    let datetime = row[column.property];
    if (datetime) {
        datetime = new Date(datetime);
        let y = datetime.getFullYear();
        let mon = datetime.getMonth() > 9 ? datetime.getMonth() : "0" + datetime.getMonth();
        let d = datetime.getDate() > 9 ? datetime.getDate() : "0" + datetime.getDate();
        let h = datetime.getHours() > 9 ? datetime.getHours() : '0' + datetime.getHours();
        let m = datetime.getMinutes() > 9 ? datetime.getMinutes() : '0' + datetime.getMinutes();
        let s = datetime.getSeconds() > 9 ? datetime.getSeconds() : '0' + datetime.getSeconds();
        return y + '-' + mon + '-' + d + ' ' + h + ':' + m + ':' + s;
    }
    return "";
}

function getLabelByCode(code, enums) {
    for(const obj of enums) {
        if (code == obj.code) {
            return obj.label;
        }
    }
    return '';
}
export {
    getLogTypeName,
    getStatusName,
    dateFormatter,
    getLabelByCode}